package zhanglinwei.cryptotools.core.wrapper;

import org.springframework.core.env.PropertySource;
import zhanglinwei.cryptotools.core.resolver.CryptoablePropertyResolver;
import zhanglinwei.cryptotools.core.source.CacheCryptoablePropertySource;
import zhanglinwei.cryptotools.core.source.CryptoablePropertySource;

public class CryptoablePropertySourceWrapper <T> extends PropertySource<T> implements CryptoablePropertySource<T> {

    private final CacheCryptoablePropertySource<T> cacheCryptoableDelegate;

    public CryptoablePropertySourceWrapper(PropertySource<T> delegate, CryptoablePropertyResolver resolver) {
        super(delegate.getName(), delegate.getSource());
        cacheCryptoableDelegate = new CacheCryptoablePropertySource<>(delegate, resolver);
    }

    @Override
    public PropertySource<T> getDelegate() {
        return cacheCryptoableDelegate;
    }

    @Override
    public Object getProperty(String propertyName) {
        return cacheCryptoableDelegate.getProperty(propertyName);
    }

    @Override
    public void refresh() {

    }
}
